using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;

namespace DOTS.DOD.LESSON3
{
    struct RotateAndMoveSpeed : IComponentData
    {
        public float RotateSpeed;
        public float MoveSpeed;
    }

    public class RotateAndMoveSpeedAuthoring : MonoBehaviour
    {
        [Range(0, 360)] public float RotateSpeed;
        [Range(0, 10)] public float MoveSpeed;

        class Baker : Baker<RotateAndMoveSpeedAuthoring>
        {
            public override void Bake(RotateAndMoveSpeedAuthoring authoring)
            {
                var entity = GetEntity(TransformUsageFlags.None);
                AddComponent(entity, new RotateAndMoveSpeed()
                {
                    RotateSpeed = math.radians(authoring.RotateSpeed),
                    MoveSpeed = authoring.MoveSpeed,
                });
            }
        }
    }
}